from django.conf.urls.defaults import patterns, include, url
from django.views.generic import DetailView, ListView, TemplateView
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.contrib.auth.views import login,password_change
from inventory.models import Item,Location
from inventory.views import *


# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('inventory.views',
    #index 
	url(r'^$', main_page), # TemplateView.as_view(template_name='inventory/index.html')),
	url(r'^search/$', search),
	url(r'^update/$', update),
	url(r'^action/$', action),
	url(r'^add/$', update, {'action':'add'}),
	url(r'^edit/(?P<obj_id>\d+)/$', update, {'action':'edit'}),
	
	#browse has a lot of actions depending on what is supplied
	url(r'^browse/$', browse, {'page_id':'1', 'per_page':'20'}),
	url(r'browse/(?P<page_id>\d+)/$', browse, {'per_page':'20'}),
	url(r'^browse/(?P<page_id>\d+)/(?P<per_page>\d+)/$', browse),
	
	url(r'^changepw/$', changepw),
	url(r'^logout/$', logout_page),
	
)
	
urlpatterns += patterns('',
    url(r'^login/$', 'django.contrib.auth.views.login', {'template_name': 'inventory/login.html'}),
#	url(r'^changepw$', password_change, {'template_name' : 'inventory/changepw.html'}),
    url(r'^admin/', include(admin.site.urls)),
)

urlpatterns += staticfiles_urlpatterns()